package student;

public class StudenList {
    private static final int DEFAULT_SIZE = 10;//定义一个final的常量
    private Student[] students=new Student[DEFAULT_SIZE];
    private int usedsize;//记录当前实际学生数量
    public StudenList(){
        //创建studentlist时就初始化学生信息，以后就在此基础是变动
        students[0]=new Student("张三","男","计算机3",001);
        students[1]=new Student("李四","男","计算机3",002);
        students[2]=new Student("王二","男","计算机3",003);
        students[3]=new Student("张伟","男","计算机3",004);
        usedsize=4;//当前4名学生
    }

  public Student getStudent(int pos){//按照下标返回学生
        return students[pos];
  }

  public void setStudent(Student student){//增加学生，默认在数组最后加入
        students[usedsize]=student;
  }

  public void setStudent(int pos, Student student){
        students[pos]=student;//在特定下标修改学生（为了删除学生而设置）
  }

    public int getUsedsize() {
        return usedsize;
    }

    public void setUsedsize(int usedsize) {
        this.usedsize = usedsize;
    }

}
